import http from '@/utils/http/axios'
// /gwp/select id 获取指定id的记录
// /gwp/list strategyid 获取与指定网关策略绑定的记录列表
// /gwp/create record 创建新记录
// /gwp/update record 修改已有记录
// /gwp/delete id 删除指定id的记录

enum Api {
    strategyTypes = '/strategy/types',
    strategySelect = '/strategy/select/',
    strategyUpdate = '/strategy/update/',
    strategyCreate = '/strategy/create/',
    strategyDelete = '/strategy/delete',
    strategyCount = '/strategy/count',
    gwpDelete = '/gwp/delete',
    gwpList = '/gwp/list',
    gwpCreate = '/gwp/create',
    gwpUpdate = '/gwp/update',
    gwpSelect = '/gwp/select',
}

/**
 * @description: 获取指定ID的记录
 */
export function gwpSelect(params: any) {
    return http.request({
        url: Api.gwpSelect ,
        method: 'POST',
        params,
    }, {
        isParseToJson: true,
        isShowMessage: true,
        successMessageText: '修改成功',
        errorMessageText: '修改失败'
    })
}

/**
 * @description: 更新网关记录
 */
export function gwpUpdate(params: any) {
    return http.request({
        url: Api.gwpUpdate ,
        method: 'POST',
        params,
    }, {
        isParseToJson: true,
        isShowMessage: true,
        successMessageText: '修改成功',
        errorMessageText: '修改失败'
    })
}

/**
 * @description: 创建网关记录
 */
export function gwpCreate(params: any) {
    return http.request({
        url: Api.gwpCreate ,
        method: 'POST',
        params,
    }, {
        isParseToJson: true,
        isShowMessage: true,
        successMessageText: '添加成功',
        errorMessageText: '添加失败'
    })
}

/**
 * @description: 网关策略记录列表
 */
export function gwpList(params: any) {
    return http.request({
        url: Api.gwpList ,
        method: 'POST',
        params,
    })
}

/**
 * @description: 根据id删除网关策略记录
 */
export function gwpDelete(params: any) {
    return http.request({
        url: Api.gwpDelete ,
        method: 'POST',
        params,
    }, {
        isShowMessage: true,
        successMessageText: '删除成功',
        errorMessageText: '删除失败'
    })
}

/**
 * @description: 获取策略类型
 */
export function strategyTypes(params: any) {
    return http.request({
        url: Api.strategyTypes ,
        method: 'POST',
        params,
    })
}

/**
 * @description: 查询策略列表
 */
export function strategySelect(params: any, stype) {
    return http.request({
        url: Api.strategySelect + stype,
        method: 'POST',
        params,
    })
}

/**
 * @description: 更新某项策略
 */
export function strategyUpdate(params: any, stype) {
    return http.request({
        url: Api.strategyUpdate + stype,
        method: 'POST',
        params,
    }, {
        isShowMessage: true,
        successMessageText: '保存成功',
        errorMessageText: '保存失败',
        isTransformRequestResult: false
    })
}

/**
 * @description: 创建策略
 */
export function strategyCreate(params: any, stype) {
    return http.request({
        url: Api.strategyCreate + stype,
        method: 'POST',
        params,
    })
}

/**
 * @description: 删除策略
 */
export function strategyDelete(params: any) {
    return http.request({
        url: Api.strategyDelete,
        method: 'POST',
        params,
    },{
        isShowMessage: true,
        successMessageText: '删除成功',
        errorMessageText: '删除失败'
    })
}

/**
 * @description: 查询总的策略条数
 */
export function strategyCount(params: any) {
    return http.request({
        url: Api.strategyCount,
        method: 'POST',
        params,
    })
}
